//! Header for the class MediaLibrary
#ifndef MEDIALIBRARY_H
#define MEDIALIBRARY_H
//! Represents the media library which contains all created MusicMedia (Factory pattern)
/*!
	The class MediaLibrary is able to allocate memory for new Songs, Albums and
	MusicCollections. The pointer of the newly created media will be stored in
	the list of the library. This is needed for freeing the allocated memory
	at destruction of an Object.
	\class MediaLibrary
	\author Andreas Lehner
	\date 06.12.2012
*/
#include <list>
#include "Object.h"
#include "MusicMedia.h"
#include "Song.h"
#include "Album.h"
#include "MusicCollection.h"

class MediaLibrary {
public:
	//! DTor of class MediaLibrary
	/*!
		The destructor is used to free all allocated memory for the music medias.
	*/
	~MediaLibrary();
	//! Function to create a new Song and push it back to the list
	/*!
		The function creates a Song and pushes it back to the list mLibrary.
		Only pointers will be stored.
		\param name The name of the Song
		\param interpret The name of the interpret of the Song
		\param album The Album the song belongs to
		\param duration The duration of the Song in minutes and seconds
		\return Song* The newly created song
	*/
	Song* CreateSong(std::string name, std::string interpret, Album * album, TDuration duration);
	//! Function to create a new Album and push it back to the list
	/*!
		The function creates a Album and pushes it back to the list mLibrary.
		Only pointers will be stored.
		\param albumname The name of the Album
		\param albuminterpret The name of the interpret of the Album
		\return Album* The newly created album
	*/
	Album* CreateAlbum(std::string const& albumname, std::string const& albuminterpret);
	//! Function to create a new MusicCollection and push it back to the list
	/*!
		The function creates a MusicCollection and pushes it back to the list mLibrary.
		Only pointers will be stored.
		\param collectionname The name of the MusicCollection
		\return MusicCollection* The newly created music collection
	*/
	MusicCollection* CreateCollection(std::string const& collectionname);

private:
	//helper method for deleting a media in the list used in the destructor
	static void deletemedia(MusicMedia * media);
	//list of all MusicMedias that were created
	std::list<MusicMedia*> mLibrary;
};

#endif